jQuery(function($) {
    $('#add-form').validate({
        errorElement: 'div',
        errorClass: 'help-block',
        focusInvalid: true,
        rules: {
            name: {
                required: true
            },
            ico: {
                required: true
            }
        },
        messages: {
            name: {
                required: "请正确填写菜单名称。"
            },
            ico: {
                required: "请正确填写菜单图标。"
            }
        },
        invalidHandler: function (event, validator) { //display error alert on form submit
            $('.alert-danger', $('.login-form')).show();
        },
        highlight: function (e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
            $(e).next('i').removeClass('icon-info-sign').removeClass('icon-ok-sign').addClass('icon-remove-sign');
        },
        success: function (e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(e).parent().find('i').removeClass('icon-remove-sign').addClass('icon-ok-sign');
            $(e).remove();
        },
        errorPlacement: function (error, element) {
            error.insertAfter(element.parent().parent());
        },
        submitHandler: function (form) {
            form.submit();
        }
    });



});
